Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid warning when $ROS_AUTOMATIC_DISCOVERY_RANGE is not defined #343

Merged
merged 3 commits into from
Nov 27, 2024

Conversation

JEnoch
Copy link
Member

@JEnoch JEnoch commented Nov 27, 2024

Following #311 , on Humble the following warning is logged when $ROS_AUTOMATIC_DISCOVERY_RANGE environment variable is not set:
WARN tokio-runtime-worker ThreadId(09) zenoh_plugin_ros2dds: ROS_AUTOMATIC_DISCOVERY_RANGE will be ignored since it's not supported before ROS 2 Iron

The cause is Config::default_automatic_discovery_range() setting the value to Some(RosAutomaticDiscoveryRange::Subnet) if the environment variable is not defined.

This PR fixes this.

@JEnoch JEnoch requested a review from evshary November 27, 2024 10:59
Copy link

PR missing one of the required labels: {'documentation', 'breaking-change', 'new feature', 'dependencies', 'bug', 'internal', 'enhancement'}

@JEnoch JEnoch added the bug Something isn't working label Nov 27, 2024
Ok("SYSTEM_DEFAULT") => Some(RosAutomaticDiscoveryRange::SystemDefault),
Ok(value) => {
warn!(
r#"Invalid value for environment variable ROS_AUTOMATIC_DISCOVERY_RANGE ("{value}"). Using "SUBNET" instead "#
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether we should have a warning here
According to here, we shouldn't change any discovery setting. I use Subnet because I think our default configuration should be Subnet.
WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to here, we shouldn't change any discovery setting

Reading this doc, the case of an invalid string is not specified. So we have 2 options:

  • either panic, as we can't return an Error in this default_automatic_discovery_range() function
  • either ignoring the invalid value and use the default one which is Subnet according to the doc. I think it's also good to log a warning in this case to point the invalid value to the user.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind. I missed the line Ok(value)

Copy link
Contributor

@evshary evshary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad. I found I misunderstood the changes

@JEnoch JEnoch merged commit d4dba0e into main Nov 27, 2024
10 checks passed
@JEnoch JEnoch deleted the fix_ROS_AUTOMATIC_DISCOVERY_RANGE_default_value branch November 28, 2024 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants